<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>居民区党项目基本信息</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<SCRIPT language=JavaScript type=text/JavaScript>
window.onload = function(){
	var flag = $('#flag').val();
	if(flag != ""){
		alert(flag);
	}
	$('#flag').val('');
};

function delProject(timeKey){
	var r = confirm("确定要删除吗?");
	if(r){
		$.post(
				"/djzx/CommunityProjectAction!delProject.action",
				{
					"communityProject.timeKey":timeKey
				},
				function(data){
					alert(data.message);
					if(data.success){
						location.href="/djzx/CommunityProjectAction!getProjectListForPage.action";
					}
				},
				"json"
				)
	}
}

function toAddProject(){
	window.location.href="/djzx/CommunityProjectAction!toAddProject.action";
}

function toEditProject(timeKey){
	window.location.href="/djzx/CommunityProjectAction!toEditProject.action?communityProject.timeKey=" + timeKey + "&editFrom=1";;
}

function searchProject(){
	ajaxProject(1);
}

function firstPage(){
	ajaxProject(1);
}

function prevPage(){
	var start =parseInt($("#start").html());
	if(start <= 1){
		start = 1;
	}else{
		start--;
	}
	ajaxProject(start);
}

function nextPage(){
	var start =parseInt($("#start").html());
	var count = parseInt($("#pageCount").html());
	if(start >= count){
		start = count;
	}else{
		start++;
	}
	ajaxProject(start);
}

function endPage(){
	var last = parseInt($("#pageCount").html());
	ajaxProject(last);
}

function ajaxProject(start){
	var param = $.trim($('#param').val());
	var paramValue = $.trim($('#paramValue').val());
	var name = "";
	var content = "";
	var attendNum = "";
	
	if(param == 'name'){
		name = paramValue;
	}else if(param == 'content'){
		content = paramValue;
	}else if(param == 'attendNum'){
		if(isNaN(paramValue) || paramValue == ''){
			alert("请输入数字！");
			return false;
		}
		attendNum = parseInt(paramValue);
	}
	
	$.ajax({
		url:'${pageContext.request.contextPath}/CommunityProjectAction!searchProjectList.action',
		data:{
			"page.currPage":start,
			"communityProject.name":name,
			"communityProject.content":content,
			"communityProject.attendNum":attendNum
		},
		type:'post',
		dataType:'json',
		success:function(data){
			var str="";
			if(data.map.length>0){
				$.each(data.map,function(i){
					str+='<tr><td class="td_01">'+data.map[i].index+
					'</td><td class="td_01"><a href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey='+data.map[i].timeKey+'" target="_blank">'+data.map[i].name+'</a>'+
					'</td><td class="td_01">'+data.map[i].content+
					'</td><td class="td_01">'+data.map[i].attendNum+
					'</td><td class="td_01">'+data.map[i].partyName+
					'</td><td class="td_01">'+data.map[i].workMemberNum+
					'</td><td class="td_01">'+data.map[i].date+
					'</td><td nowrap class="td_01"><a href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey='+data.map[i].timeKey+'" target="_blank">查看</a>|<a href="javascript:void(0)" onclick="toEditProject('+data.map[i].timeKey+')">编辑</a>|<a href="javascript:void(0)" onclick="delProject('+data.map[i].timeKey+')">删除</a></td></tr>';
				});
			}
			$("#nodeContent").html(str);
			$("#start").html(data.object.currPage);
			$("#pageCount").html(data.object.pageCount);
			$("#count").html(data.object.count);
		}
	}); 
}

function tree(tag,imgTag){
	if($('#' + tag).css('display') == 'none'){
		$('#' + tag).show();
		$('#' + imgTag).attr('src','/djzx/images/minus.png');
	}else{
		$('#' + tag).hide();
		$('#' + imgTag).attr('src','/djzx/images/plus.png');
	}
}

function toProjectActivity(){
	window.location.href = "/djzx/CommunityProjectActivityAction!getProjectActivityListForPage.action";
}

$(document).ready(function(){
	// 移动到指定位置，并打开指定总支节点
	var communityGeneralPartyKey = $('#communityGeneralPartyKey').val();
	if(communityGeneralPartyKey != ''){
		var tag = 'child_' + communityGeneralPartyKey;
		var imgTag = 'img_' + communityGeneralPartyKey;
		//vScrollTo(tag);
		tree(tag, imgTag);
	}
});

// 垂直滚动到
function vScrollTo(tag){
	var top = $('#' + tag).offset().top;
	$('html,body').animate({scrollTop: top}, 500); 
}

function goback(){
	history.back(-1);
}

</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<input id="flag" value="${flag }" type="hidden"/>
<input id="communityGeneralPartyKey" value="${communityGeneralPartyKey }" type="hidden"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">项目信息查询</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td class="td_page">
	  <%-- 查询参数：
      <select name="param" id="param">
      	<option value="name">项目名称</option>
        <option value="content">项目内容</option>
        <option value="attendNum">参加人数</option>
      </select>
             参数值：
      <input name="paramValue" id="paramValue" type="text" class="input" size="10">
      <input type="button" class="buttonface02" value=" 查询 " onclick="searchProject()"> --%>
      <input type="button" class="buttonface02" value=" 所有项目活动" onclick="toProjectActivity()">
	  <input type="button" class="buttonface02" value=" 新增项目 " onclick="toAddProject()">
	  <!-- <input type="button" class="buttonface02" value=" 返回 " onclick="goback()"> -->
    </td>
  </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr> 
    <td nowrap class="td_top">序号</td>
    <td nowrap class="td_top">党组织名称</td>
    <td nowrap class="td_top">地址</td>
    <td nowrap class="td_top">居委会电话</td>
    <td nowrap class="td_top">党总支书记</td>
    <td nowrap class="td_top">书记联系方式</td>
    <td nowrap class="td_top">居委会主任</td>
	<td nowrap class="td_top">主任联系方式</td>
  </tr>
  <tbody id="nodeContent">
  <s:iterator value="communityGeneralPartyList" var="cgp" status="statu1">
  <tr> 
    <td class="td_01">${statu1.index+1 }</td>
    <td class="td_01">
    	<img id="img_${cgp.timeKey }" style="vertical-align: middle;" onClick="tree('child_${cgp.timeKey }','img_${cgp.timeKey }');" src="/djzx/images/plus.png" width="19" height="20">
    	<a onClick="tree('child_${cgp.timeKey }','img_${cgp.timeKey }');" href="javascript: void(0);">${cgp.name }</a>
    </td>
    <td class="td_01">${cgp.address }</td>
    <td class="td_01">${cgp.tel }</td>
    <td class="td_01">${cgp.secretary }</td>
    <td class="td_01">${cgp.tel1 }</td>
	<td class="td_01">${cgp.director }</td>
    <td class="td_01">${cgp.tel2 }</td>
  </tr>
  <tr>
  	<td colspan="9">
      <table id="child_${cgp.timeKey }" style="display: none;" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
	      <td nowrap class="td_form03">项目名称</td>
	      <!-- <td nowrap class="td_form03">项目内容</td> -->
	      <td nowrap class="td_form03">可参加人数</td>
	      <!-- <td nowrap class="td_form03">党组织名称</td> -->
	      <td nowrap class="td_form03">在职党员数</td>
	      <td nowrap class="td_form03">日期</td>
		  <td nowrap class="td_form03">操作</td>
	    </tr>
        <s:iterator value="communityProjectList" var="c" status="statu2">
  		<s:if test="#c.communityGeneralParty.timeKey==#cgp.timeKey">
        <tr>
	      <td class="td_form01">
	    	<a href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey=${c.timeKey}" target="_blank">${c.name }</a>
	      </td>
	      <%-- <td class="td_form01">${c.content }</td> --%>
	      <td class="td_form01">${c.attendNum }</td>
	      <%-- <td class="td_form01">${c.communityGeneralParty.name }</td> --%>
	      <td class="td_form01">${c.workMemberNum }</td>
	      <td class="td_form01">${c.date }</td>
		  <td nowrap class="td_form01">
			<a href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey=${c.timeKey}" target="_blank">查看</a>|
			<a href="#" onclick="toEditProject(${c.timeKey})">编辑</a>|
			<a href="#" onclick="delProject(${c.timeKey })">删除</a>
		  </td>
	    </tr>
	    </s:if>
	    </s:iterator>
  	  </table>
  	</td>
  </tr>
  </s:iterator>	
  <%-- <tr> 
    <td nowrap class="td_top">序号</td>
    <td nowrap class="td_top">项目名称</td>
    <td nowrap class="td_top">项目内容</td>
    <td nowrap class="td_top">可参加人数</td>
    <td nowrap class="td_top">党组织名称</td>
    <td nowrap class="td_top">在职党员数</td>
    <td nowrap class="td_top">日期</td>
	 <td nowrap class="td_top">操作</td>
  </tr>
  <tbody id="nodeContent">
  <s:iterator value="communityProjectList" var="c" status="statu">
  <tr> 
    <td class="td_01">${statu.index+1 }</td>
    <td class="td_01">
    	<a href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey=${c.timeKey}" target="_blank">${c.name }</a>
    </td>
    <td class="td_01">${c.content }</td>
    <td class="td_01">${c.attendNum }</td>
    <td class="td_01">${c.communityGeneralParty.name }</td>
    <td class="td_01">${c.workMemberNum }</td>
    <td class="td_01">${c.date }</td>
	<td nowrap class="td_01">
		<a href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey=${c.timeKey}" target="_blank">查看</a>|
		<a href="#" onclick="toEditProject(${c.timeKey})">编辑</a>|
		<a href="#" onclick="delProject(${c.timeKey })">删除</a>
	</td>
  </tr>
  </s:iterator> --%>
  </tbody>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap width="95%" class="td_top"></td>
  </tr>
</table>
<table width="95%"  border="0" cellpadding="0" cellspacing="0" class="table02" align="center">
  <tr>
    <td height="30" align="right">
	    <img src="/djzx/images/1.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="">首页</a>　
	    <img src="/djzx/images/2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="">上一页</a>　 
	    <img src="/djzx/images/2-2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="">下一页</a>　 
	    <img src="/djzx/images/3.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="">末页</a>　　
	         当前第<span id="start">${page.currPage}</span>页,共<span id="pageCount">${page.pageCount}</span>页,共<span id="count">${page.count}</span>条记录
    </td>
  </tr>
</table>
</body>
</html>